<template>
	<view>
		<nav-bar fontColor="#FFFFFF" :title="form.productName"></nav-bar>
		<view class="topBgColor">
			<!-- <view class="topTitle">
				<span>{{title}}</span>
				<view style="display: flex;margin-left: 30rpx;">
					<view class="tag1">低利率</view>
					<view class="tag2">低门槛</view>
					<view class="tag1">放款快</view>
				</view>
			</view> -->
		</view>
		<view class="addressBox">
			<view class="tag2">
				可融资
			</view>
			<view style="font-size: 25rpx;height: 80rpx;line-height: 110rpx;font-weight: bold;">当前可用额度（元）</view>
			<view
				style="color: #ef1a1a;font-weight: bold;width: 100%;height: 120rpx;margin: 0 auto;display: flex;justify-content: center;">
				<view style="font-size: 30rpx;line-height: 130rpx;">￥</view>
				<view style="font-size: 80rpx;line-height: 100rpx;">{{creditLeft}}</view>
<!-- 				<view style="color: #000000;line-height: 130rpx;margin-left: 10rpx;font-size: 25rpx;">万</view> -->
			</view>
			<view style="color: #a5a5a5;">年利率{{dayRate}}%</view>
			<view style="width: 100%;display: flex;justify-content: space-around;" @click="apply">
				<view style="width: 90%;height: 100rpx;line-height: 100rpx;border-radius: 25px;background-image: linear-gradient(to right, #6a11cb 0%, #2575fc 100%);color: #FFFFFF;margin-top: 40rpx;" >立即融资</view>
			</view>
		</view>
		<view class="centerBox">
			
			<!-- <uni-card title="融资记录" :isFull="true"  extra="查看"></uni-card> -->
			<view class="centerBoxtitle top">关联核心贸易伙伴</view>
			<uni-card title="华致酒行连锁管理股份有限公司" extra="已绑定" :isFull="true"
				thumbnail="/static/img/hz.jpg">
			</uni-card>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				creditLeft: '',
				dayRate: '',
				form:{},
				applyStatus: false
			}
		},
		onLoad(e) {
			this.form = JSON.parse(e.id)
			console.log(this.form)
			
			// this.getCustInfo();
		},
		onShow() {
			this.getLimit();
		},
		methods: {
			getLimit(){
				let opt = {
					url:'finance/customerCredit/getCustInfor',
					method:'POST'
				};
				let params = {
					CustomerNo: uni.getStorageSync('userInfo').customerId,
					FinProductNo: this.form.productNo
				}
				this.$http.httpTokenRequest(opt,params).then(res =>{
					if(res.data.data != null && res.data.data.status == 'ACTIVED'){
						this.creditLeft = res.data.data.remainLimit
						
						this.dayRate = res.data.data.dayRate
						this.dayRate = this.dayRate * 360;
						this.dayRate = this.dayRate.toFixed(2)
						this.applyStatus = true;
					}
					else{
						uni.showToast({
							title:'请先开通产品再进行融资',
							icon:'none'
						});
					}
					
				})
			},
			getCustInfo(){
				
				let opt = {
					url:'basic/customer/getMyCustInfor',
					method:'POST'
				};
				this.$http.httpTokenRequest(opt,{}).then(res =>{
					if( res.data.data.jdCreditStatus === 'ACCESS' &&  res.data.data.jdAccessStatus === 'ACCESS'){
						this.applyStatus = true;
					}
					else{
						uni.showToast({
							title:'请先开通产品再进行融资',
							icon:'none'
						});
					}
				})
			},
			apply() {
				if(this.applyStatus){
					let formData = JSON.stringify(this.form)
					uni.navigateTo({
						url: '/pages/limit/financing-apply?id='+ formData
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #f4f4f4;
	}

	.flex {
		display: flex;
	}
	.tag {
		color: dodgerblue;
		background: #FFFFFF;
		width: 120rpx;
		height: 50rpx;
		text-align: center;
		border-radius: 25px;
		font-size: 25rpx;
		line-height: 50rpx;
		background: #b5e3ff;
		position: absolute;
		right: 5%;
		margin-top: 30rpx;
	
	}
	
	.tag1 {
		color: #00d900;
		background: #FFFFFF;
		width: 120rpx;
		height: 50rpx;
		text-align: center;
		border-radius: 25px;
		font-size: 25rpx;
		line-height: 50rpx;
		margin: 20rpx 10rpx;
	}
	
	.tag2 {
		color: #ffffff;
		background: #00b409;
		width: 120rpx;
		height: 50rpx;
		text-align: center;
		border-radius: 25px;
		font-size: 25rpx;
		line-height: 50rpx;
		margin: 20rpx 10rpx;
	}
	.topBgColor {
		width: 100%;
		height: 400rpx;
		background-image: linear-gradient(to right, #6a11cb 0%, #2575fc 100%);
	}

	.topTitle {
		display: flex;
		height: 100rpx;
		padding: 20rpx;

		span {
			font-size: 40rpx;
			color: #FFFFFF;
			font-weight: bold;
			line-height: 100rpx;
			margin-left: 20rpx;
		}

		image {
			height: 40rpx;
			width: 40rpx;

		}

		.jiantou {
			line-height: 120rpx;
		}

	}

	.addressBox {
		width: 95%;
		margin: 0 auto;
		background: #FFFFFF;
		border-radius: 15rpx;
		margin-top: 50rpx;
		position: absolute;
		height: 500rpx;
		top: 5%;
		left: 2.5%;
		text-align: center;
	}

	.centerBox {
		width: 95%;
		margin: 0 auto;
		margin-top: 180rpx;
		.centerBoxtitle {
			font-size: 35rpx;
			color: #000000;
			font-weight: bold;
			margin: 20rpx 0;
		}

		.centerBoxDetail {
			color: #a5a5a5;
			font-size: 28rpx;
			letter-spacing: 2rpx;
			margin: 20rpx 0;
		}

		.top {
			margin-top: 70rpx;
		}
	}

	.bottomBox {
		position: fixed;
		width: 100%;
		bottom: 0;
		margin-bottom: 20rpx;
		z-index: 1000;
	}

	.buttonBox {
		width: 100%;
		margin: 0 auto;
		display: flex;
		justify-content: space-around;

		// margin-top: 200rpx;
	}

	.button_fix {
		width: 90%;
		height: 70rpx;
		// margin: 0 auto;
		color: #FFFFFF;
		background: #2749C8;
		font-weight: bold;
		letter-spacing: 5rpx;
		font-size: 28rpx;
		line-height: 70rpx;

	}
</style>